defAdmCmd(new AbstractAdmCmdImpl("js"){
	Inputs:"JsShell.inputs",
	execute:function(cmdLine,ctx){
		var data=getChannelData(ctx.channel());
		data.put(AdmChannelDataConsts.CurCmd, this);
        data.put(this.Inputs, new StringBuilder());
	},
	executeContinue:function(cmdLine,ctx){
		var data=getChannelData(ctx.channel());
		var inputs = data.get(this.Inputs);
        var token = cmdLine.nextToken();
        if ("-q".equals(token)) {
            data.remove(this.Inputs);
            data.remove(AdmChannelDataConsts.CurCmd);
        } else if ("-ef".equals(token)) {
            var outputs=this.executeFile(cmdLine.nextToken());
            ctx.writeAndFlush(outputs + "\r\n");
        } else if ("-e".equals(token)) {
            var outputs = this.executeScript(inputs.toString());
            ctx.writeAndFlush(outputs + "\r\n");
            data.put(this.Inputs, new StringBuilder());
        } else if ("-c".equals(token)) {
            data.put(this.Inputs, new StringBuilder());
        } else {
            inputs.append(cmdLine.getStr());
        }
	},
	usage:function(){
		return "-q quit\r\n"//
        + "-ef <file> run script\r\n" //
        + "-c clear inputs\r\n"//
        + "-e execute\r\n";//
	},
	executeFile:function(file){
		try {
            var inputs = FileUtils.readFileToString(new File(file), "utf8");
            return this.executeScript(inputs);
        } catch (e) {
            return e.getMessage();
        }
	},
	executeScript:function(inputs){
		var outputs = new StringBuilder();
        try {
        	var sw = new StringWriter();
            var result = ScriptEngineUtil.eval(inputs,new PrintWriter(sw));
            outputs.append(sw.toString());
            outputs.append(result);
        } catch (err) {
        	print(err);
            outputs.append(String(err));
        }
        return outputs.toString();
	}
});